<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="com.mongodb.client.MongoCursor,org.bson.Document,org.bson.types.ObjectId,mongo.Department" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>更新系部信息</title> 
</head>
<body>
	<%
	    Department Department = new Department();
	    ObjectId _id = new ObjectId(request.getParameter("_id"));
		Document document = Department.findByid(_id);
		String id = document.getString("id");
		String name = document.getString("name");
		String explain = document.getString("explain");
		String remark = document.getString("remark");
	%>
	<jsp:include page="../navbar.html" />
	<div class="container-fluid">
		<div class="row">
			<div class="col-md-1 col-md-offset-3">
				<a href="departmentServlet?method=list">
					<button type="button" class="btn btn-default"><em class="fa fa-chevron-left"></em> 返回</button>
				</a>
			</div>
		</div>
    	<div class="row mt15">
			<div class="col-md-6 col-md-offset-3">
				<div class="panel">
                	<div class="panel-body">
                  		<h4 class="page-header mt0">修改系部信息</h4>
                  			<form name="departform" role="form" action="departmentServlet" method="post"  onsubmit="return check(this);" class="form-horizontal mt20">
	                  	    <fieldset>
				              <div class="form-group">
				                  <label class="col-md-2 control-label">ID</label>
				                  <div class="col-md-9">
				                     <input class="form-control" type="text" name="id" value="<%=id %>"  placeholder="请输入系部ID" readonly />
				                  </div>
				               </div> 
			                </fieldset>
		               		<fieldset>
			               		<div class="form-group">
			                  		<label class="col-md-2 control-label">名称</label>
		                  			<div class="col-md-9">
		                     			<input class="form-control" type="text" name="name" value="<%=name %>" placeholder="请输入系部名称" />
		                  			</div>
		               			</div>	
		               		</fieldset> 
		                	<fieldset>
			               		<div class="form-group">
			                  		<label class="col-md-2 control-label">说明</label>
			                  		<div class="col-md-9">
			                     		<input class="form-control" type="text" name="explain" value="<%=explain %>" placeholder="请输入系部说明" />
			                  		</div>
			               		</div>	
		               		</fieldset>   
		               		<fieldset>
			              		<div class="form-group">
			               			<label class="col-md-2 control-label">备注</label>
				               		<div class="col-md-9">
			               				<textarea class="form-control no-resize" name="remark" placeholder="请输入系部备注" rows="6"><%=remark %></textarea>
			               			</div>
			               		</div>
		               		</fieldset>  
		               		<input type="hidden" name="_id" value="<%=_id %>">
		               		<div class="col-md-10 col-md-offset-1">
		               			<div class="col-md-6">
		               				<button type="submit" class="btn btn-primary btn-block" name="method" value="update">确定</button> 
		               			</div>
		               			<div class="col-md-6">
		               				<button type="reset" class="btn btn-default btn-block">重置</button> 
		               			</div>
		               		</div>
		               		
	              			</form>
               		</div>
            	</div>
         	</div>
       </div>
    </div>
    <script type="text/javascript">  
    //表单提交前进行数据验证，数据合法则返回true表单提交
    function check(departform) {   
        if(departform.name.value=="") {  
        	swal("系部名称不能为空","请重新输入","warning");   
            return false;  
        }  
        else if(departform.explain.value=="") {  
       	    swal("系部说明不能为空","请重新输入","warning");   
            return false;  
        }  
        return true;  
    }      
</script>
</body>
</html>